package com.socialbank.web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.socialbank.web.dto.BankMoneyCodeDto;
import com.socialbank.web.dto.BankMoneyDto;
import com.socialbank.web.dto.BankRewardDto;
import com.socialbank.web.dto.PointExchangeRewardDto;
import com.socialbank.web.dto.UserPointDto;
import com.socialbank.web.service.PointService;
import com.socialbank.web.util.SocialBankJsonUtil;
/**
 * 后台积分控制器
 * @ClassName: PointController
 * @author tangyao_ft@163.com
 * @date 2017年10月9日 下午3:04:59
 */
@Controller
@RequestMapping("point")
public class PointController extends BaseController {
	
	@Autowired
	private PointService pointService;
	
	/**
	 * 个人积分明细
	 * @Title: getPointDetail
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param userPointDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("pointDetail")
	public void getPointDetail(HttpServletRequest request, HttpServletResponse response,@RequestBody UserPointDto userPointDto){
		Map<String,Object> pointDetail = pointService.getPointDetail(userPointDto);
		String result = SocialBankJsonUtil.mapToJsonString(pointDetail);
		print(response, result);
	}
	
	/**
	 * 新增礼品
	 * @Title: addReward
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param BankRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("addReward")
	public void addReward(HttpServletRequest request, HttpServletResponse response,@RequestBody BankRewardDto bankRewardDto){
		Map<String,Object> add = pointService.addReward(bankRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(add);
		print(response, result);
	}
	
	/**
	 * 删除礼品
	 * @Title: deleteReward
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("deleteReward")
	public void deleteReward(HttpServletRequest request, HttpServletResponse response,@RequestBody BankRewardDto bankRewardDto){
		Map<String,Object> delete = pointService.deleteReward(bankRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(delete);
		print(response, result);
	}
	
	/**
	 * 编辑礼品
	 * @Title: updateReward
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("updateReward")
	public void updateReward(HttpServletRequest request, HttpServletResponse response,@RequestBody BankRewardDto bankRewardDto){
		Map<String,Object> update = pointService.updateReward(bankRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(update);
		print(response, result);
	}
	
	
	/**
	 * 确认换购码是否可用
	 * @Title: checkRewardCode
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param pointExchangeRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("checkRewardCode")
	public void checkRewardCode(HttpServletRequest request, HttpServletResponse response,@RequestBody PointExchangeRewardDto pointExchangeRewardDto){
		Map<String,Object> checkRewardCode = pointService.checkRewardCode(pointExchangeRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(checkRewardCode);
		print(response, result);
	}
	
	/**
	 * 通过换购码查看对应换购的商品
	 * @Title: getRewardGoodbyCode
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param pointExchangeRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("getRewardGoodbyCode")
	public void getRewardGoodbyCode(HttpServletRequest request, HttpServletResponse response,@RequestBody PointExchangeRewardDto pointExchangeRewardDto){
		Map<String,Object> rewardGood = pointService.getRewardGoodbyCode(pointExchangeRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(rewardGood);
		print(response, result);
	}
	
	/**
	 * 后台完成换购
	 * @Title: completeExchange
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param pointExchangeRewardDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("completeExchange")
	public void completeExchange(HttpServletRequest request, HttpServletResponse response,@RequestBody PointExchangeRewardDto pointExchangeRewardDto){
		Map<String,Object> completeExchange = pointService.completeExchange(pointExchangeRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(completeExchange);
		print(response, result);
	}
	
	/**
	 * 查询专属理财列表
	 * @Title: getExclusiveFinancial
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankMoneyDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("exclusiveFinancial")
	public void getExclusiveFinancial(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyDto bankMoneyDto){
		Map<String,Object> exclusiveFinancial = pointService.getExclusiveFinancial(bankMoneyDto);
		String result = SocialBankJsonUtil.mapToJsonString(exclusiveFinancial);
		print(response, result);
	}
	
	/**
	 * 增加专属理财产品
	 * @Title: addExclusiveFinancial
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankMoneyDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("addExclusiveFinancial")
	public void addExclusiveFinancial(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyDto bankMoneyDto){
		Map<String,Object> exclusiveFinancial = pointService.addExclusiveFinancial(bankMoneyDto);
		String result = SocialBankJsonUtil.mapToJsonString(exclusiveFinancial);
		print(response, result);
	}
	
	/**
	 * 删除专属理财产品
	 * @Title: deleteExclusiveFinancial
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankMoneyDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("deleteExclusiveFinancial")
	public void deleteExclusiveFinancial(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyDto bankMoneyDto){
		Map<String,Object> deleteExclusiveFinancial = pointService.deleteExclusiveFinancial(bankMoneyDto);
		String result = SocialBankJsonUtil.mapToJsonString(deleteExclusiveFinancial);
		print(response, result);
	}
	
	/**
	 * 修改专属理财产品
	 * @Title: updateExclusiveFinancial
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankMoneyDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("updateExclusiveFinancial")
	public void updateExclusiveFinancial(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyDto bankMoneyDto){
		Map<String,Object> updateExclusiveFinancial = pointService.updateExclusiveFinancial(bankMoneyDto);
		String result = SocialBankJsonUtil.mapToJsonString(updateExclusiveFinancial);
		print(response, result);
	}

	/**
	 * 导入预约码的功能
	 * @Title: addBankMoneyCode
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param bankMoneyCodeDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("addBankMoneyCode")
	public void addBankMoneyCode(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyCodeDto bankMoneyCodeDto){
		Map<String,Object> addBankMoneyCode = pointService.addBankMoneyCode(bankMoneyCodeDto);
		String result = SocialBankJsonUtil.mapToJsonString(addBankMoneyCode);
		print(response, result);
	}

	
	/**
	 * 查询兑换专属理财产品的客户列表
	 * @Title: getExchangeBankMoneyOfUserList
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @return void
	 * @throws
	 */
	@RequestMapping("getUserList")
	public void getExchangeBankMoneyOfUserList(HttpServletRequest request, HttpServletResponse response,@RequestBody BankMoneyDto bankMoneyDto){
		Map<String,Object> userList = pointService.getExchangeBankMoneyOfUserList(bankMoneyDto);
		String result = SocialBankJsonUtil.mapToJsonString(userList);
		print(response, result);
	}
	
	/**
	 * 积分换购
	 * @Title: pointExchangeReward
	 * @Description: TODO
	 * @param @param request
	 * @param @param response
	 * @param @param userPointDto
	 * @return void
	 * @throws
	 */
	@RequestMapping("exchange")
	public void pointExchangeReward(HttpServletRequest request, HttpServletResponse response,@RequestBody PointExchangeRewardDto pointExchangeRewardDto){
		Map<String,Object> exchange = pointService.pointExchangeReward(pointExchangeRewardDto);
		String result = SocialBankJsonUtil.mapToJsonString(exchange);
		print(response, result);
	}
	
}
